<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Basic usage of this extension</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="intl.examples.html">范例</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="class.collator.html">Collator</a></div>
 <div class="up"><a href="intl.examples.html">范例</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="intl.examples.basic" class="section">
  <h2 class="title">Basic usage of this extension</h2>
  <p class="para">
   Each module provides two kind of APIs: a procedural one and an object
   oriented one. Both are actually identical and described in the
   corresponding document.
  </p>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <p class="para">
    All input strings must be in UTF-8 encoding. All output strings are
    also in UTF-8.
   </p>
  </p></blockquote>
  <div class="example" id="example-2417">
   <p><strong>Example #1 Example of using the procedural API</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$coll&nbsp;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">collator_create</span><span style="color: #007700">(</span><span style="color: #DD0000">'en_US'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$result&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">collator_compare</span><span style="color: #007700">(</span><span style="color: #0000BB">$coll</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"string#1"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"string#2"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

  </div>

  <div class="example" id="example-2418">
   <p><strong>Example #2 Example of using the object-oriented API</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$coll&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">Collator</span><span style="color: #007700">(</span><span style="color: #DD0000">'en_US'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$al&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$coll</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getLocale</span><span style="color: #007700">(</span><span style="color: #0000BB">Locale</span><span style="color: #007700">::</span><span style="color: #0000BB">ACTUAL_LOCALE</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #DD0000">"Actual&nbsp;locale:&nbsp;</span><span style="color: #0000BB">$al</span><span style="color: #DD0000">\n"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$formatter&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">NumberFormatter</span><span style="color: #007700">(</span><span style="color: #DD0000">'en_US'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">NumberFormatter</span><span style="color: #007700">::</span><span style="color: #0000BB">DECIMAL</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #0000BB">$formatter</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">format</span><span style="color: #007700">(</span><span style="color: #0000BB">1234567</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

  </div>
 </div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="intl.examples.html">范例</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="class.collator.html">Collator</a></div>
 <div class="up"><a href="intl.examples.html">范例</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
